﻿using Direct.IDAL.User.Jurisdiction;
using DirectSell.Model.ManagerNotice;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DirectSell.DAL.User.Jurisdiction
{
    /// <summary>
    /// 前台公告仓储层
    /// </summary>
    public class UserNoticeRepository:AbsRepository, IUserNoticeRepository
    {
        #region 首页查询前五条公告
        /// <summary>
        /// 首页查询前十条公告
        /// </summary>
        /// <returns></returns>
        public async Task<SortedList<int, Notices>> TopNotice()
        {
            string str = "SELECT TOP 5 * FROM Notice ORDER BY Sort ASC ";
            var result = await base.QueryAsync<Notices>(str);
            var list = result as IList<Notices>;
            var notice = new SortedList<int, Notices>();

            for (int i = 0; i < list.Count; i++)
            {
                notice.Add(i, list[i]);
            }
            return notice;
        }
        #endregion
    }
}
